<template>
  <div class="error-page">
    <div class="error-container">
      <!-- 404 图标 -->
      <div class="error-icon">
        <svg viewBox="0 0 200 200" class="error-svg">
          <text x="50%" y="50%" text-anchor="middle" dy=".3em" class="error-text">
            404
          </text>
        </svg>
      </div>
      
      <!-- 错误信息 -->
      <div class="error-content">
        <h1 class="error-title">页面未找到</h1>
        <p class="error-description">
          抱歉，您访问的页面不存在或已被移除。
        </p>
        <p class="error-suggestion">
          请检查URL是否正确，或返回首页继续浏览。
        </p>
      </div>
      
      <!-- 操作按钮 -->
      <div class="error-actions">
        <el-button type="primary" @click="goHome">
          <el-icon><HomeFilled /></el-icon>
          返回首页
        </el-button>
        <el-button @click="goBack">
          <el-icon><ArrowLeft /></el-icon>
          返回上页
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {useRouter} from 'vue-router'
import {ArrowLeft, HomeFilled} from '@element-plus/icons-vue'

const router = useRouter()

// 返回首页
const goHome = () => {
  router.push('/')
}

// 返回上一页
const goBack = () => {
  if (window.history.length > 1) {
    router.go(-1)
  } else {
    router.push('/')
  }
}
</script>

<style scoped>
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.error-container {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.error-icon {
  margin-bottom: 30px;
}

.error-svg {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
}

.error-text {
  font-size: 72px;
  font-weight: bold;
  fill: #ffffff;
  font-family: 'Arial', sans-serif;
}

.error-content {
  margin-bottom: 40px;
  color: #ffffff;
}

.error-title {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 16px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.error-description {
  font-size: 18px;
  margin: 0 0 12px 0;
  opacity: 0.9;
  line-height: 1.6;
}

.error-suggestion {
  font-size: 16px;
  margin: 0;
  opacity: 0.8;
  line-height: 1.5;
}

.error-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.error-actions .el-button {
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.error-actions .el-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .error-page {
    padding: 16px;
  }
  
  .error-svg {
    width: 150px;
    height: 150px;
  }
  
  .error-text {
    font-size: 56px;
  }
  
  .error-title {
    font-size: 24px;
  }
  
  .error-description {
    font-size: 16px;
  }
  
  .error-suggestion {
    font-size: 14px;
  }
  
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .error-actions .el-button {
    width: 200px;
  }
}

@media (max-width: 480px) {
  .error-svg {
    width: 120px;
    height: 120px;
  }
  
  .error-text {
    font-size: 48px;
  }
  
  .error-title {
    font-size: 20px;
  }
}
</style>